package com.zzyl.nursing.service.impl;

import cn.hutool.db.PageResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.dto.MemberProjectPageDto;
import com.zzyl.nursing.mapper.MemberOrderMapper;
import com.zzyl.nursing.service.MemberOrderService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper, NursingProject> implements MemberOrderService {

    @Override
    public List<NursingProject> getPage(MemberProjectPageDto memberProjectPageDto) {
        Page<NursingProject> page = new Page<>(memberProjectPageDto.getPageNum(), memberProjectPageDto.getPageSize());

        page = page(page, Wrappers.lambdaQuery(NursingProject.class)
                .eq(memberProjectPageDto.getStatus()!=null,NursingProject::getStatus, memberProjectPageDto.getStatus())
                .eq(memberProjectPageDto.getName()!=null&&!memberProjectPageDto.getName().isEmpty(),NursingProject::getName, memberProjectPageDto.getName()));
        List<NursingProject> nursingProjects = page.getRecords();
        return nursingProjects;
    }
}
